home *** CD-ROM | disk | FTP | other *** search
/ The Atari Compendium / The Atari Compendium (Toad Computers) (1994).iso / files / umich / utils / unixt~3h / tr.zoo / README < prev    next >
Text File  |  1991-03-07  |  3KB  |  70 lines

  1. TR.TTP:        Translate and/or delete characters.
  2.  
  3. by David Megginson, 1991
  4. Released into the Public Domain
  5.  
  6. Usage:    tr [-cds] string1 [string2]
  7.  
  8. INTRODUCTION
  9.  
  10. Here is my version of tr(1v) for the Atari ST. tr is a pure filter
  11. program (it cannot take files as arguments) which will translate or
  12. delete characters from its standard input and place the result on
  13. its standard output. tr takes three options:
  14.  
  15. -c    Use the complement of string1 (everything but..)
  16. -d    Delete characters in string1
  17. -s    Squeeze output so that multiple instances of the same
  18.     translate character are compressed into a single instance.
  19.  
  20. The strings may consist of any characters, a range in the format 
  21. <char1>-<char2>, or an octal value in the form \nnn (you may not use
  22. octal values in a range). Use \ to take - literally. This example will
  23. create a list of words in a file, one on each line:
  24.  
  25.     tr -cs a-zA-Z '\012' < myfile.txt > wordlist.txt
  26.  
  27. SPEED
  28.  
  29. For the sake of speed, I bypass the high-level i/o functions and read
  30. in large chunks of a file at once (this is portable to Unix and MSDOS,
  31. by the way). The default buffer size is 50000 bytes, but you can change
  32. it in the Makefile by adding -DBUFFER_SIZE=<whatever>. The bigger the
  33. buffer, the faster tr, but also the more memory wasted (remember, the
  34. ST is a MULTITASKING machine now, so we can't use Malloc(-1L) to grab
  35. all available memory any more without risking flames).
  36.  
  37. THOSE PESKY CARRIAGE RETURNS
  38.  
  39. For some brain-damaged reason (MSDOS,CP/M compatibility, I imagine),
  40. the ST uses "\r\n" to mark the end of a line instead of "\n" like in
  41. Unix. Many of us have recompiled programs to avoid this, but the
  42. problem of compatibility still remains. Use the -DSKIP_CR flag in the
  43. Makefile to handle '\r' correctly in the input file (I have _not_ done
  44. this for the distribution binary). Even with -DSKIP_CR, CR will usually
  45. be stripped from the output file, at least in this version.
  46.  
  47. WHAT DOES THIS COST?
  48.  
  49. Nothing, of course. After Eric Smith created MiNT and made it free to
  50. the public, how could I live with myself if I tried to make this
  51. shareware? Besides, I spent only an hour or two on it. Do feel free
  52. to post glowing messages about me to the net, though... :-)
  53.  
  54. REVISION NUMBER
  55.  
  56. You can check the revision number of your tr.ttp binaries using the
  57. RCS ident(1) command. If you don't have A. Pratt's excellent port of
  58. RCS for the Atari ST, GET IT!
  59.  
  60. USING THE SOURCE
  61.  
  62. This program is in the Public Domain, _not_ under the Gnu licensing
  63. agreement. As a result, you may incorporate it (re-compiled) into
  64. commercial packages without charge, although I would like a little
  65. credit somewhere in the documentation. The source is (I hope) good
  66. ANSI, and you will need an ANSI compiler and ANSI header files to
  67. recompile it (I use the Gnu C compiler and Eric Smith's MiNT library
  68. for GCC on the Atari ST).
  69.  
  70.